/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javafxapplicationwithcss;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.chart.AreaChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import javafx.stage.Stage;

/**
 *
 * @author Crossbone
 */
public class JavaFXApplicationWithCSS extends Application {

    @Override
    public void start(Stage stage) throws Exception {
//würde auch ber dein FXML document gehen das dann als root weiter gegeben wird
        Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));

        stage.setTitle("Beispiel chart für Temperator");
        final NumberAxis xAxis = new NumberAxis(1, 31, 1);
        xAxis.setMinorTickCount(0);
        xAxis.setLabel("Tage");
        final NumberAxis yAxis = new NumberAxis(-5, 27, 5); //geht auch ins negative 
        yAxis.setMinorTickLength(yAxis.getTickLength());
        yAxis.setLabel("Temperatur");

        yAxis.setForceZeroInRange(false);//erzwingt 0 anzeige immer

        //Chart 
        final AreaChart<Number, Number> ac
                = new AreaChart<Number, Number>(xAxis, yAxis);
        ac.setTitle("Temp monitoring");

        //nun die Graphen
        XYChart.Series seriesActive = new XYChart.Series();
        seriesActive.setName("April");
        seriesActive.getData().add(new XYChart.Data(0, 4));
        seriesActive.getData().add(new XYChart.Data(3, 10));
        seriesActive.getData().add(new XYChart.Data(6, 15));
        seriesActive.getData().add(new XYChart.Data(9, 8));
        seriesActive.getData().add(new XYChart.Data(12, 5));
        seriesActive.getData().add(new XYChart.Data(15, 18));
        seriesActive.getData().add(new XYChart.Data(18, 15));
        seriesActive.getData().add(new XYChart.Data(21, 13));
        seriesActive.getData().add(new XYChart.Data(24, 19));
        seriesActive.getData().add(new XYChart.Data(27, 21));
        seriesActive.getData().add(new XYChart.Data(30, 21));

        XYChart.Series seriesInactive = new XYChart.Series();
        seriesInactive.setName("May");
        seriesInactive.getData().add(new XYChart.Data(0, 20));
        seriesInactive.getData().add(new XYChart.Data(3, 15));
        seriesInactive.getData().add(new XYChart.Data(6, 13));
        seriesInactive.getData().add(new XYChart.Data(9, 12));
        seriesInactive.getData().add(new XYChart.Data(12, 14));
        seriesInactive.getData().add(new XYChart.Data(15, 18));
        seriesInactive.getData().add(new XYChart.Data(18, 25));
        seriesInactive.getData().add(new XYChart.Data(21, 25));
        seriesInactive.getData().add(new XYChart.Data(24, 23));
        seriesInactive.getData().add(new XYChart.Data(27, 26));
        seriesInactive.getData().add(new XYChart.Data(31, 26));

        //chart der Scene mitgeben größe definieren
        Scene scene = new Scene(ac,800,600);//hier könnte man auch über fxml dokumente arbeiten "root"
        scene.getStylesheets().add("javafxapplicationwithcss/controlStyle2.css");
        ac.getData().addAll(seriesActive, seriesInactive);
        
        stage.setScene(scene);
        stage.show();
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }

}
